package com.jydd.liaomingframe.loading;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.jydd.liaomingframe.R;
import com.jydd.liaomingframe.login.LoginActivity;
import com.lm.liaoming.base.custom.CustomBaseFragment;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class LoadingFragment extends CustomBaseFragment {

    @BindView(R.id.loadingf_ivcontent)
    ImageView loadingfIvcontent;
    @BindView(R.id.loadingf_ivtext)
    ImageView loadingfIvtext;
    @BindView(R.id.loadingf_btn_start)
    TextView loadingfBtnStart;
    @BindView(R.id.loadingf_dian)
    ImageView loadingfDian;

    public static LoadingFragment newInstance(int position) {
        Bundle args = new Bundle();
        args.putInt("position", position);
        LoadingFragment fragment = new LoadingFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_loading, container, false);
        ButterKnife.bind(this, view);
        return view;

    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        int position = getArguments().getInt("position", 0);
        if (position == 0) {
            loadingfBtnStart.setVisibility(View.INVISIBLE);
            loadingfIvcontent.setImageResource(R.mipmap.loading_fragment1);
            loadingfIvtext.setImageResource(R.mipmap.loading_fragmenttext1);
            loadingfDian.setImageResource(R.mipmap.loading1);
        } else if (position == 1) {
            loadingfBtnStart.setVisibility(View.INVISIBLE);
            loadingfIvcontent.setImageResource(R.mipmap.loading_fragment2);
            loadingfIvtext.setImageResource(R.mipmap.loading_fragmenttext2);
            loadingfDian.setImageResource(R.mipmap.loading2);
        } else if (position == 2) {
            loadingfBtnStart.setVisibility(View.INVISIBLE);
            loadingfIvcontent.setImageResource(R.mipmap.loading_fragment3);
            loadingfIvtext.setImageResource(R.mipmap.loading_fragmenttext3);
            loadingfDian.setImageResource(R.mipmap.loding3);
        } else if (position == 3) {
            loadingfBtnStart.setVisibility(View.VISIBLE);
            loadingfIvcontent.setImageResource(R.mipmap.loading_fragment4);
            loadingfIvtext.setImageResource(R.mipmap.loading_fragmenttext4);
            loadingfDian.setImageResource(R.mipmap.loding4);
        }
    }

    @OnClick(R.id.loadingf_btn_start)
    public void onViewClicked() {

        startActivity(new Intent(getActivity(), LoginActivity.class));
        getActivity().finish();
    }
}
